<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>赛诺菲_西南区 销量统计系统</title>
	<%@ include file="../../inc/fileHead.jsp"%>
		<script type="text/javascript" src="js/FusionCharts/FusionCharts.js"></script>
	</head>
	<body class="easyui-layout">
		<div data-options="region:'north',title:'查询条件',iconCls:'icon-search'" style="height:60px">
		<div>
			开始时间:
			<input id="startDate" type="text" class="easyui-datebox"
				required="required"></input>
			结束时间:
			<input id="endDate" type="text" class="easyui-datebox"
				required="required"></input>
			sales名称:
			<input required="true" class="easyui-combobox" id="salesId"
				data-options="  
                    url:'BaseAction_selectGetSalesName',  
                    valueField:'id',  
                    textField:'name',  
                    panelHeight:'auto'
            " />
			<a href="javascript:void(0)" class="easyui-linkbutton"
				iconCls="icon-search" plain="true" onclick="submit()">查询</a>
		</div>
		<div id="dlg" class="easyui-dialog"
			style="width: 800px; height: 480px; top: 100px; padding: 10px 20px"
			closed="true"
			data-options="iconCls:'icon-save',resizable:true,modal:true">
			<table id="dgsales" title="sales 数据记录" class="easyui-datagrid"
				style="width: 700px; height: 250px" rownumbers="true"
				fitColumns="true" singleSelect="true">
				<thead>
					<tr>
						<th field="customerName" width="50">
							客户名称
						</th>
						<th field="productName" width="50">
							产品
						</th>
						<th field="amount" width="50">
							销量
						</th>
					</tr>
				</thead>
			</table>
			<table id="dgpm" title="PM 数据记录" class="easyui-datagrid"
				style="width: 700px; height: 250px" rownumbers="true"
				fitColumns="true" singleSelect="true">
				<thead>
					<tr>
						<th field="customerName" width="50">
							客户名称
						</th>
						<th field="productName" width="50">
							产品
						</th>
						<th field="amount" width="50">
							销量
						</th>
					</tr>
				</thead>
			</table>
		</div>
		</div>
		<div id="chartContainer" data-options="region:'center',title:'查询结果'" style="text-align: center;">
			<img src="html/report.jpg">
		</div>
		<script type="text/javascript">    
		function submit(){ 
		
		var tag = true;
		if($('#salesId').combobox("getValue")==""){ 
			tag = false;
		}else if($('#startDate').datebox("getValue")==""){ 
			tag = false;
		}else if($('#endDate').datebox("getValue")==""){ 
			tag = false;
		}
		if(tag== false){
			$.messager.alert('提示','请输入查询条件');
			return;
		}
		if($('#startDate').datebox("getValue").substring(0,4)!=$('#endDate').datebox("getValue").substring(0,4)){
			$.messager.alert('提示','开始时间和结束时间不要跨年');
			return;
		}
		 var d1 = $.fn.datebox.defaults.parser($('#startDate').datebox("getValue"));  
         var d2 = $.fn.datebox.defaults.parser($('#endDate').datebox("getValue"));  
         if(d1>d2){
    		$.messager.alert('提示','开始时间不能晚于结束时间');
			return;    	
         } 
		
		var url="ReportAction_findDifferentReport?salesId="+$('#salesId').combobox("getValue")+"&startDate="+$('#startDate').combobox("getValue")+"&endDate="+$('#endDate').combobox("getValue");
               var myChart = new FusionCharts( "js/FusionCharts/MSColumn3D.swf",  
                   "myChartId", "800", "500", "0" );
     	 				myChart.setJSONUrl(url);
      					myChart.render("chartContainer"); 
            }  
                 
        function myJS(d){
        	var param = d.split(",");
        	var salesId = param[0];
        	var productId = param[1];
        	var startDate = param[2];
        	var endDate = param[3];
            $('#dlg').dialog('open').dialog('setTitle','记录');
            $('#dgsales').datagrid({
                 url:'ReportAction_findSalesDetails',  
				 queryParams: {
					salesId: salesId,  
    				productId: productId,
    				startDate: startDate,
    				endDate: endDate
				 }
			});
			$('#dgpm').datagrid({
                 url:'ReportAction_findPmDetails',  
				 queryParams: {
					salesId: salesId,  
    				productId: productId,
    				startDate: startDate,
    				endDate: endDate
				 }
			});
        }    
    </script>
	</body>
</html>